Enabling root, Configuring Files Using vi, Starting/Stopping/Restarting Services, & Installing Some Software
Okay let's just jump right into it. First we are going to enable the root user, know normally this is frowned upon but since we are using the server edition and should only be accessed by system administrators we should be okay enabling the root user.
Enabling root Account:
Type sudo passwd root, you will then be asked to enter password this is your user password that you assigned durning the installation.
Next you will be asked to Enter new UNIX Password, this is going to be the password for the root account so make it different then your user account. Once you entered the password you will hit enter and be asked to re-enter your root password and hit enter again. Now you will be back to your command prompt.
Now to enter the root account simply type su and hit enter. Enter the root account password and hit enter again. Your are now in root. You will have access to the entire filesystem and edit or delete any file or folder. So from here on in be very careful with what you do and before editing any file or deleting any file make a backup of it. To do this simply type this command:
cp filename filename.bak
This will copy the file and add the extension .bak that stands for backup.
To restore the file simply delete the corrupted file and replace with the backup file by typing the following commands:
rm filename
cp .bak filename
That's it.
Editing files using the vi command
Okay when we did the installation of Ubuntu we let the installation just go with a DHCP assigned IP address, but since we are working with a server we don't want it to change IP addresses. So we are going to edit the interfaces file to make it a static IP address. A few things you will need is a IP address that is not being used, Subnet Mask, Default Gateway address, and DNS Server IP address. Now to edit this file just type:
vi /etc/network/interfaces
Now make the file look like this to this press the Insert key to enter edit mode:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.1
Now once you have made all the changes to the file you need to save it by going a :wq
and that is it.
Now we are going to edit the hosts file the same way.
vi /etc/hosts
Now make the file look like this:
127.0.0.1 localhost.localdomain localhost
192.168.0.100 server1.example.com server1
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Then save the host file like you saved the interface file and your are done with the hosts file.
Lastly we are going to edit the sources file so you can broaden your selection of installable packages through the Ubuntu repositories. Edit the following file:
vi /etc/apt/sources.list
Now make the file look like this:
#
# deb cdrom:[Ubuntu-Server 6.06 _Dapper Drake_ - Release i386 (20060531)]/ dapper main
restricted
# deb cdrom:[Ubuntu-Server 6.06 _Dapper Drake_ - Release i386 (20060531)]/ dapper main
restricted
deb http://de.archive.ubuntu.com/ubuntu/ dapper main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://us.archive.ubuntu.com/ubuntu/ dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper universe
## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
deb http://security.ubuntu.com/ubuntu dapper-security universe
deb-src http://security.ubuntu.com/ubuntu dapper-security universe
Now save this file and quit vi.
Starting/Stopping/Restarting Services
Since we changed the interface configuration file we need to restart the networking service. This is easily done by typing the following command:
/etc/init.d/networking restart
This will restart the networking service and if anything goes wrong it will fail. If everything goes right it will say ok.
You will be starting/stopping/restarting services all through this guide so for right now we will end this section of this post.
Installing Some Software
Since we also edited the sources file we need to know update it and upgrade the distrubition. Do this by typing the following commands:
apt-get update
Once this command is done running you then want to type :
apt-get upgrade
This take a little to run but it will upgrade your entire system.
Once this upgrade is complete we want to be able remotely access this server so we are going to install some software packages called ssh which stands for Secure Shell. To do this enter the following command:
apt-get install ssh openssh-server
You will be asked if you wish to continue by entering a Y and hitting enter.
Once this install is complete you will be able to access this server from anywhere by using a terminal or a program PuTTy.
Now let's install a series of packages called a LAMP stack. To do this enter this command:
apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
Once again you will be asked if you want to continue just reply with a Y and hit enter.
You now have a fully functional Apache Web Server that supports PHP5 and a MySQL Server. The only thing left to do is to set the root password for MySQL Server. Please note this root password is solely for the SQL server and does not change the root password for the entire system. To do this type the following commands:
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('areallygoodpassword');
quit
This completes this posting of enabling root, configuring files using vi, starting/stopping/restarting services, and installing some software. From here we are going to contain the posts to specific parts of the server. So you will be able to pick and choose what you want to actually do with the server. For example you may just want to have a web server in which case you may only want to go as far as the next post. You may want to have a email and web server so you will have to have the next two posts and so far and so on.
Till next time.
Enabling root Account:
Type sudo passwd root, you will then be asked to enter password this is your user password that you assigned durning the installation.
Next you will be asked to Enter new UNIX Password, this is going to be the password for the root account so make it different then your user account. Once you entered the password you will hit enter and be asked to re-enter your root password and hit enter again. Now you will be back to your command prompt.
Now to enter the root account simply type su and hit enter. Enter the root account password and hit enter again. Your are now in root. You will have access to the entire filesystem and edit or delete any file or folder. So from here on in be very careful with what you do and before editing any file or deleting any file make a backup of it. To do this simply type this command:
cp filename filename.bak
This will copy the file and add the extension .bak that stands for backup.
To restore the file simply delete the corrupted file and replace with the backup file by typing the following commands:
rm filename
cp .bak filename
That's it.
Editing files using the vi command
Okay when we did the installation of Ubuntu we let the installation just go with a DHCP assigned IP address, but since we are working with a server we don't want it to change IP addresses. So we are going to edit the interfaces file to make it a static IP address. A few things you will need is a IP address that is not being used, Subnet Mask, Default Gateway address, and DNS Server IP address. Now to edit this file just type:
vi /etc/network/interfaces
Now make the file look like this to this press the Insert key to enter edit mode:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 192.168.0.1
Now once you have made all the changes to the file you need to save it by going a :wq
and that is it.
Now we are going to edit the hosts file the same way.
vi /etc/hosts
Now make the file look like this:
127.0.0.1 localhost.localdomain localhost
192.168.0.100 server1.example.com server1
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Then save the host file like you saved the interface file and your are done with the hosts file.
Lastly we are going to edit the sources file so you can broaden your selection of installable packages through the Ubuntu repositories. Edit the following file:
vi /etc/apt/sources.list
Now make the file look like this:
#
# deb cdrom:[Ubuntu-Server 6.06 _Dapper Drake_ - Release i386 (20060531)]/ dapper main
restricted
# deb cdrom:[Ubuntu-Server 6.06 _Dapper Drake_ - Release i386 (20060531)]/ dapper main
restricted
deb http://de.archive.ubuntu.com/ubuntu/ dapper main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://us.archive.ubuntu.com/ubuntu/ dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper universe
## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
deb http://security.ubuntu.com/ubuntu dapper-security universe
deb-src http://security.ubuntu.com/ubuntu dapper-security universe
Now save this file and quit vi.
Starting/Stopping/Restarting Services
Since we changed the interface configuration file we need to restart the networking service. This is easily done by typing the following command:
/etc/init.d/networking restart
This will restart the networking service and if anything goes wrong it will fail. If everything goes right it will say ok.
You will be starting/stopping/restarting services all through this guide so for right now we will end this section of this post.
Installing Some Software
Since we also edited the sources file we need to know update it and upgrade the distrubition. Do this by typing the following commands:
apt-get update
Once this command is done running you then want to type :
apt-get upgrade
This take a little to run but it will upgrade your entire system.
Once this upgrade is complete we want to be able remotely access this server so we are going to install some software packages called ssh which stands for Secure Shell. To do this enter the following command:
apt-get install ssh openssh-server
You will be asked if you wish to continue by entering a Y and hitting enter.
Once this install is complete you will be able to access this server from anywhere by using a terminal or a program PuTTy.
Now let's install a series of packages called a LAMP stack. To do this enter this command:
apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
Once again you will be asked if you want to continue just reply with a Y and hit enter.
You now have a fully functional Apache Web Server that supports PHP5 and a MySQL Server. The only thing left to do is to set the root password for MySQL Server. Please note this root password is solely for the SQL server and does not change the root password for the entire system. To do this type the following commands:
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('areallygoodpassword');
quit
This completes this posting of enabling root, configuring files using vi, starting/stopping/restarting services, and installing some software. From here we are going to contain the posts to specific parts of the server. So you will be able to pick and choose what you want to actually do with the server. For example you may just want to have a web server in which case you may only want to go as far as the next post. You may want to have a email and web server so you will have to have the next two posts and so far and so on.
Till next time.